/*
 * Created on 2004-10-12
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package tw.com.jinwei.utils;

import java.net.URL;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class LogHelper {

	private final static String CONFIG_FILE = "/conf/log4j.properties";
	private static boolean initialized = false;

	public static Logger getLog(Class component) {
		if (!initialized) {
			init();
		}
		return Logger.getLogger(component.getName());
	}

	synchronized static private void init() {
		if (initialized) {
			return;
		}
		URL url = LogHelper.class.getResource(CONFIG_FILE);
		if (null == url) {
			System.err.println(new StringBuffer("config file ").append(
					CONFIG_FILE).append(" is not found"));
		}
		PropertyConfigurator.configure(url);
		initialized = true;
	}

	public static void main(String[] args) {
		Logger log = LogHelper.getLog(LogHelper.class);
		log.debug("Hello");
	}
}
